package core;

import utils.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by jimmyhsu on 2016/12/19.
 */
public class Logout extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getSession().invalidate();
        String type = req.getParameter("type");
        if (!StringUtils.isEmpty(type) && "superadmin".equals(type)) {
            resp.getWriter().print("<script>location.href='../view/Admin/login.html';</script>");
        } else {
            resp.getWriter().print("<script>location.href='../view/Student/login.html';</script>");
        }
    }
}
